package com.zhipu.resetbalance.pop;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import androidx.annotation.NonNull;

import com.lxj.xpopup.core.CenterPopupView;
import com.zhipu.resetbalance.R;
import com.zhipu.resetbalance.listener.ChooseClickCallback;
import com.zhipu.resetbalance.listener.ChooseClickCallback1;
import com.zhipu.resetbalance.mobile.event.NumberedEntity;
import com.zhipu.resetbalance.utils.InitializeUtils;

public class AddNumberPopup extends CenterPopupView {

    /**
     *
     */
    private NumberedEntity mNumberedEntity;

    public AddNumberPopup(@NonNull Context context) {
        super(context);
    }


    public AddNumberPopup(@NonNull Context context,NumberedEntity mNumberedEntity) {
        super(context);
        this.mNumberedEntity = mNumberedEntity;
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.popup_add_number;

    }


    @Override
    protected void onCreate() {
        super.onCreate();
        /**
         * 请输入编号
         */
        EditText NameTester = findViewById(R.id.NameTester);
        if(null != mNumberedEntity){
            NameTester.setText(mNumberedEntity.NumberedName);
        }
        /**
         * 关闭
         */
        findViewById(R.id.Cancel).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

        /**
         * 确认添加
         */
        findViewById(R.id.ConfirmAdd).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                String mData = NameTester.getText().toString();
                if(TextUtils.isEmpty(mData)){
                    InitializeUtils.getDefaultMaker().show("请输入编号");
                    return;
                }
                if(null != mChooseClickCallback){
                    mChooseClickCallback.onChooseClickCallback(mData);
                }
                dismiss();
            }
        });
    }


    private ChooseClickCallback1 mChooseClickCallback;
    public ChooseClickCallback1 getChooseClickCallback() {
        return mChooseClickCallback;
    }
    public void setChooseClickCallback(ChooseClickCallback1 mChooseClickCallback) {
        this.mChooseClickCallback = mChooseClickCallback;
    }
}
